package com.example.qxfw.tourqx.controller;

import com.example.qxfw.common.SysResult;
import com.example.qxfw.common.entity.qx.Weather;
import com.example.qxfw.common.entity.yj.IndustryWarning;
import com.example.qxfw.common.entity.zy.SpecialFcst;
import com.example.qxfw.common.entity.zy.TourFcst;
import com.example.qxfw.common.entity.zy.TourStations;
import com.example.qxfw.tourqx.service.IndustryWarningService;
import com.example.qxfw.tourqx.service.SpecialFcstService;
import com.example.qxfw.ybzz.service.TourFcstService;
import com.example.qxfw.ybzz.service.TourStationsService;
import com.example.qxfw.ybzz.service.WeatherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

@ApiIgnore
@Api(tags = "旅游气象-专题服务")
@RestController
@CrossOrigin
@RequestMapping("/ztfw")
public class ZtfwController {

    @Autowired
    private TourStationsService tourStationsService;

    @Autowired
    private TourFcstService tourFcstService;

    @Autowired
    private WeatherService weatherService;

    @Autowired
    private IndustryWarningService industryWarningService;

    @Autowired
    private SpecialFcstService specialFcstService;

    @ApiOperation("获取站点信息")
    @GetMapping("/getTourStations")
    public SysResult getTourStations(){
        List<TourStations> list = tourStationsService.getList1();
        return SysResult.success(list);
    }

    @ApiOperation("获取最新时间")
    @GetMapping("/getMaxTime")
    public SysResult getMaxTime(){
        TourFcst maxTime = tourFcstService.getMaxTime();
        return SysResult.success(maxTime);
    }

    @ApiOperation("获取站点名称")
    @GetMapping("/getStationName")
    public SysResult getStationName(){
        List<String> stationName = tourStationsService.getStationName();
        return SysResult.success(stationName);
    }

    @ApiOperation("获取天气代码")
    @GetMapping("/getWeatherCode")
    public SysResult getWeatherCode(){
        List<Weather> weather = weatherService.getWeather();
        return SysResult.success(weather);
    }

    @ApiOperation("更新景点预报")
    @PostMapping("/updateTourFcst")
    public SysResult updateTourFcst(@RequestBody TourFcst tourFcst){
        TourFcst result = tourFcstService.update(tourFcst);
        if (result != null){
            return SysResult.success(result);
        }else {
            return SysResult.fail("更新预报失败！！！");
        }

    }

    @ApiOperation("获取景点预报")
    @GetMapping("/getTourFcst")
    public SysResult getTourFcst(String dateChar,String timeChar,String nTimes,String nTimes24,String nTimes12,String stationName,String forecastType){
        List<TourFcst> list = tourFcstService.getList(dateChar, timeChar, nTimes, nTimes24, nTimes12, stationName, forecastType);
        return SysResult.success(list);
    }

    @ApiOperation("查询灾情")
    @GetMapping("/getIndustryWarning")
    public SysResult getIndustryWarning(String industryType,String dateChar1,String dateChar2){
        List<IndustryWarning> list = industryWarningService.getList(industryType, dateChar1, dateChar2);
        return SysResult.success(list);
    }

    @ApiOperation("景观查询")
    @GetMapping("/getSpecialFcst")
    public SysResult getSpecialFcst(String dateTime1,String dateTime2,String typeNames,String stationId){
        List<SpecialFcst> list = specialFcstService.getList(dateTime1, dateTime2, typeNames, stationId);
        return SysResult.success(list);
    }

    @ApiOperation("获取时次")
    @GetMapping("/getTimeChar")
    public SysResult getTimeChar(String forecastType,String dateChar){
        List<String> timeChar = tourFcstService.getTimeChar(forecastType, dateChar);
        return SysResult.success(timeChar);
    }
}
